//
//  ZHLEEComposeButton.swift
//  ZHLEE_Blog_Swift_Pro
//
//  Created by ZHLEEBlander on 15/10/23.
//  Copyright © 2015年 ZHLEEBlander. All rights reserved.
//

import UIKit

let Compose_Button_W: CGFloat = 80
let Compose_Button_H: CGFloat = 110

class ZHLEEComposeButton: UIButton {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        //button的size
        size = CGSizeMake(Compose_Button_W, Compose_Button_H)
        
        //文字居中
        titleLabel?.textAlignment = NSTextAlignment.Center
        
        //文字颜色
        setTitleColor(RGB(r: 100, g: 100, b: 100), forState: UIControlState.Normal)
        
        //imageView的contentMode
        imageView?.contentMode = .Center
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        //图片位置设置
        imageView?.x = 0
        imageView?.y = 0
        imageView?.width = self.width
        imageView?.height = self.width
        
        //调整label
        titleLabel?.x = 0
        titleLabel?.y = self.width
        titleLabel?.width = self.width
        titleLabel?.height = self.height - self.width
    }

}
